home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.crl.com!usenet
- From: Richard Berman <sts@crl.com>
- Newsgroups: comp.object,comp.lang.c++
- Subject: Re: A design question
- Date: Sat, 24 Feb 1996 21:21:29 -0800
- Organization: Software Technology Service
- Message-ID: <312FF1D9.7B02@crl.com>
- References: <1996Feb22.234825.18755@dcs.warwick.ac.uk> <pvcybpuqx6p.fsf@hln56.pki-nbg.philips.de>
- NNTP-Posting-Host: crl11.crl.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win16; I)
-
- Harald Wellmann wrote:
- >
- > In article <1996Feb22.234825.18755@dcs.warwick.ac.uk> miro@dcs.warwick.ac.uk (Miroslav J Walker) writes:
- >
- > I'm trying to model input from a user being processed over a series of
- > steps.
- > Input is parsed, put into a queue and then interpreted on a timer. My
- > question is how to model the idea of it being the same bit of data
- > (essentially) taking on several forms as it proceeds along the 'pipeline' of
- > processing.
- >
- > There's a book called "Design Patterns" by Erich Gamma, where the pattern
- > you seem to be thinking of is called a "Chain of Responsibility".
- >
- > (The book is very useful, I think, but maybe not for beginners.)
- >
- > The idea of this pattern is to define a class `Event' encapsulating
- > the data to be processed along the chain.
- >
- > Then there is an abstract base class `EventHandler' with methods
- > `forward(Event&)' and `process(Event&)' and an attribute
- > `EventHandler* next_handler'.
- >
- > You can derive several types of event handlers from this class,
- > processing the event in a different way.
- >
- > Then you construct instances of these handlers and link them to form a chain.
- >
- > Each handler will process the event in its own style and then forward
- > it to the next handler.
- >
- > For more details, read the book!
-
- Of course, a state table might do the trick as well.
-
- -rb
- --
- ------------------------------------------------------------
- Richard Berman Vox: (213) 258-7525
- Software Technology Service Fax: (213) 258-9483
- 3737 Division Street, Los Angeles, CA 90065
- sts@crl.com <URL:http://www.crl.com/~sts/>
- ------------------------------------------------------------
-